package com.haina.shop.mapper;

import com.github.pagehelper.Page;
import com.haina.shop.domain.Prod;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.haina.shop.domain.ProdTag;
import com.haina.shop.dto.ProdDTO;
import com.haina.shop.vo.PageVo;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author 48077
 * @description 针对表【tz_prod(商品)】的数据库操作Mapper
 * @createDate 2024-07-31 18:34:29
 * @Entity com.haina.shop.domain.Prod
 */
public interface ProdMapper extends BaseMapper<Prod> {


    /**
     * 获取新品推荐商品列表
     * @param dto
     * @return
     */
    Page<Prod> pageByNew(ProdDTO dto);
    /**
     * 通过分组标签id（tagId）获取商品列表
     * @param tagId
     */
    Page<Prod> page(Long tagId);
     @Select("select * from yami_shops.tz_prod where prod_id=#{prodId}")
    Prod getById(Long prodId);


    @Select("select * from tz_prod where status=1 and total_stocks>0 limit #{current}, #{size}")
    List<Prod> selectByStatus(PageVo pageVo);

    @Select("select count(*) from tz_prod where status=1 and total_stocks>0")
    long selectCount();

    @Select("select count(*) from tz_prod where status=1 and category_id=#{categoryId}")
    long selectCount1(long categoryId);
    @Select("select * from tz_prod where status=1 and category_id=#{categoryId}")
    List<Prod> selectByCategory(long categoryId);
}



